package gameobj;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import manager.ElementManager;
import manager.ImageManager;
import render.SimpleModel;
import window.MainWindow;

public class SpawnPoint extends GameObject {
	private long time = 0;
	Random rd = new Random();
	
	List<Integer> enemylist = new ArrayList<>(); 
	List<Integer> bosslist = new ArrayList<>();
	List<Integer> itemlist = new ArrayList<>();
	
	ElementManager em = ElementManager.get();
	ImageManager im = ImageManager.get();
	
	public void add(int time, String type) {
		switch(type)
		{
			case "enemy":
				enemylist.add(time);break;
			case "item":
				itemlist.add(time);break;
			case "boss":
				bosslist.add(time);break;
		}
	}

	@Override
	public void ObjRun() {
		time++;
		for(int i : enemylist)
		{
			if(i == time)
			{
				int x = rd.nextInt(MainWindow.WINDOWX);
				Enemy enemy = new Enemy();
				enemy.setModel(new SimpleModel("4.png-enemy"));
				enemy.setX(x);
				enemy.setH(100);
				enemy.setW(100);
				em.add(ElementType.ENEMY, enemy);
				
				enemy.setBulletModel(new SimpleModel("13.png-fire"));
			}
		}
		
		for(int i:bosslist)
		{
			if(i==time)
			{
				Boss boss = new Boss();
				boss.setModel(new SimpleModel("4.png-boss"));
				boss.setX(300);
				boss.setH(100);
				boss.setW(100);
				em.add(ElementType.BOSS, boss);
				
				boss.setBulletModel(new SimpleModel("10.png-fire"));
			}
		}
		
	}

}
